#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QVariant>
#include <QString>
#include <QtQml>
#include <QtWebEngine/qtwebengineglobal.h>
#include "loginservice.h"
#include "treemodel.h"
#include "clockstattreemodel.h"
#include "clockcontroller.h"
#include "settings.h"

//QString base_url,api_url;


int main(int argc, char *argv[])
{
    QCoreApplication::setOrganizationName("MySoft");
    QCoreApplication::setApplicationName("Ins");
    //注册组件到QML
    qmlRegisterType<LoginService>("LoginService", 1, 0, "LoginService");
    qmlRegisterType<ClockStatTreeModel>("ClockStatTreeModel",1,0, "ClockStatTreeModel");
    qmlRegisterType<ClockController>("ClockController",1,0,"ClockController");

//    # if defined(Q_OS_ANDROID)
//        base_url = "http://192.168.0.104:8070/";
//    # else
//        base_url = "http://www.yiliaoqixie.com/";
//    # endif
//    api_url = base_url+"v1/";
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);

    QtWebEngine::initialize();

    QQmlApplicationEngine engine;

    Settings *settings = new Settings();

    engine.rootContext()->setContextProperty("base_url",BASE_URL);
    engine.rootContext()->setContextProperty("api_url",API_URL);
    engine.rootContext()->setContextProperty("settings",settings);

    engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}
